package switchviz.graphic.gauge;

import javax.media.opengl.GL;
import javax.media.opengl.GLAutoDrawable;

import org.jdom.Element;

import switchviz.graphic.GraphicEventListener;
import switchviz.graphic.GraphicFactory;

public class GaugePreviewEventListener extends GraphicEventListener
{

	private IGauge _gauge = null;
	
	public GaugePreviewEventListener(String type, Element node)
	{
		_gauge = GraphicFactory.getInstance().getGauge(type, node);
		_gauge.setDemo(true);
		_gauge.setDetailLevel(1);
	}
	
	@Override
	public void display(GLAutoDrawable drawable)
	{	
		super.display(drawable);
		GL gl = drawable.getGL();
		gl.glScalef(0.7f, 0.7f, 0.7f);
		//gl.glRotatef(20, 1.0f, 0.0f, 0.0f);
		gl.glRotatef(-35, 0.0f, 1.0f, 0.0f);
		rotateEachCell(gl);
		_gauge.draw(gl);
	}



	public void init(GLAutoDrawable drawable)
	{
		super.init(drawable);
		_gauge.initialize(drawable.getGL());
	}
}
